#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <stdio.h>
using namespace std;

class Date
{
public:
    Date(int year = 1, int day = 1)
        :_year(year)
        ,_mouth(1)
        ,_day(day)
    {
        int mouthday[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
        while ((_day - mouthday[_mouth]) > 0)
        {
            if (_mouth == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
            {
                if ((_day - 29) > 0)
                {
                    day -= 29;
                    ++_mouth;
                    continue;
                }
            }
            _day -= mouthday[_mouth];
            ++_mouth;
        }

    }

    void print()
    {
        printf("%4d-", _year);
        printf("%2d-", _mouth);
        printf("%2d\n", _day);
    }

    friend istream& operator>>(istream& in, Date& D);

private:
    int _year;
    int _mouth;
    int _day;
};

istream& operator>>(istream& in, Date& D)
{
    cin >> D._year >> D._day;
    return in;
}

int main() {
    Date D;
    while (cin >> D) {
        D.print();
    }
}